<?php

function jquery_init() {
if (!is_admin()) {
wp_deregister_script('jquery');

}elseif (is_admin()){


}
}
add_action('init', 'jquery_init');


/**
 * P tag removal from shortcodes
 *
 */

function remove_wpautop($content) { 
    $content = do_shortcode( shortcode_unautop($content) ); 
    $content = preg_replace( '#^<\/p>|^<br \/>|<p>$#', '', $content );
    return $content;
}

function ShortenText($text)

{

// Change to the number of characters you want to display

$chars_limit = 25;

$chars_text = strlen($text);

$text = $text." ";

$text = substr($text,0,$chars_limit);

$text = substr($text,0,strrpos($text,' '));

// If the text has more characters that your limit,
//add ... so the user knows the text is actually longer

if ($chars_text > $chars_limit)

{

$text = $text."...";

}

return $text;

}

function ShortenText2($text)

{

// Change to the number of characters you want to display

$chars_limit = 9;

$chars_text = strlen($text);

$text = $text." ";

$text = substr($text,0,$chars_limit);

$text = substr($text,0,strrpos($text,' '));

// If the text has more characters that your limit,
//add ... so the user knows the text is actually longer

if ($chars_text > $chars_limit)

{

$text = $text."...";

}

return $text;

}


add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 205, 130, true ); // Normal post thumbnails



/** 2 Columns */
function col2_shortcode( $atts, $content = null ) {
   return '<div class="one-half">'.remove_wpautop($content).'</div>';
}
add_shortcode('col2', 'col2_shortcode');



/** 2 Columns Last */
add_shortcode( 'col2_last', 'col2_last_shortcode' );
function col2_last_shortcode( $atts, $content = null ) {
    return '<div class="one-half last">' .remove_wpautop($content). '</div>';
}

/** 3 Columns */
function col3_shortcode( $atts, $content = null ) {
   return '<div class="one-third">'.remove_wpautop($content).'</div>';
}
add_shortcode('col3', 'col3_shortcode');



/** 3 Columns Last */
add_shortcode( 'col3_last', 'col3_last_shortcode' );
function col3_last_shortcode( $atts, $content = null ) {
    return '<div class="one-third last">' .remove_wpautop($content). '</div>';
}

/** 4 Columns */
function col4_shortcode( $atts, $content = null ) {
   return '<div class="one-fourth">'.remove_wpautop($content).'</div>';
}
add_shortcode('col4', 'col4_shortcode');



/** 4 Columns Last */
add_shortcode( 'col4_last', 'col4_last_shortcode' );
function col4_last_shortcode( $atts, $content = null ) {
    return '<div class="one-fourth last">' .remove_wpautop($content). '</div>';
}

/** 5 Columns */
function col5_shortcode( $atts, $content = null ) {
   return '<div class="one-fifth">'.remove_wpautop($content).'</div>';
}
add_shortcode('col5', 'col5_shortcode');



/** 5 Columns Last */
add_shortcode( 'col5_last', 'col5_last_shortcode' );
function col5_last_shortcode( $atts, $content = null ) {
    return '<div class="one-fifth last">' .remove_wpautop($content). '</div>';
}

/** 6 Columns */
function col6_shortcode( $atts, $content = null ) {
   return '<div class="one-sixth">'.remove_wpautop($content).'</div>';
}
add_shortcode('col6', 'col6_shortcode');



/** 6 Columns Last */
add_shortcode( 'col6_last', 'col6_last_shortcode' );
function col6_last_shortcode( $atts, $content = null ) {
    return '<div class="one-sixth last">' .remove_wpautop($content). '</div>';
}

/** One-Third Columns */
function col1_3_shortcode( $atts, $content = null ) {
   return '<div class="one-third">'.remove_wpautop($content).'</div>';
}
add_shortcode('col1_3', 'col1_3_shortcode');

/** One-Third Columns Last */
function col1_3_last_shortcode( $atts, $content = null ) {
   return '<div class="one-third last">'.remove_wpautop($content).'</div>';
}
add_shortcode('col1_3_last', 'col1_3_last_shortcode');


/** Two-Third Columns */
function col2_3_shortcode( $atts, $content = null ) {
   return '<div class="two-third">'.remove_wpautop($content).'</div>';
}
add_shortcode('col2_3', 'col2_3_shortcode');

/** Two-Third Columns Last */
function col2_3_last_shortcode( $atts, $content = null ) {
   return '<div class="two-third last">'.remove_wpautop($content).'</div>';
}
add_shortcode('col2_3_last', 'col2_3_last_shortcode');

/** One-Fourth Columns */
function col1_4_shortcode( $atts, $content = null ) {
   return '<div class="one-fourth">'.remove_wpautop($content).'</div>';
}
add_shortcode('col1_4', 'col1_4_shortcode');

/** One-Fourth Columns Last */
function col1_4_last_shortcode( $atts, $content = null ) {
   return '<div class="one-fourth last">'.remove_wpautop($content).'</div>';
}
add_shortcode('col1_4_last', 'col1_4_last_shortcode');

/** Three-Fourth Columns */
function col3_4_shortcode( $atts, $content = null ) {
   return '<div class="three-fourth">'.remove_wpautop($content).'</div>';
}
add_shortcode('col3_4', 'col3_4_shortcode');

/** Three-Fourth Columns Last */
function col3_4_last_shortcode( $atts, $content = null ) {
   return '<div class="three-fourth last">'.remove_wpautop($content).'</div>';
}
add_shortcode('col3_4_last', 'col3_4_last_shortcode');


/**
 * Slug
 *
 */

function the_slug($postID="") {
	
	global $post;
	$postID = ( $postID != "" ) ? $postID : $post->ID;
	$post_data = get_post($postID, ARRAY_A);
	$slug = $post_data['post_name'];
	return $slug;
}


/**
 * Menu
 *
 */
 
if (function_exists('add_theme_support')) {
    add_theme_support('menus');
}

	
	
function locus_addmenus() {
	register_nav_menus(
		array(
			'main_nav' => 'The Main Menu',
		)
	);
}
add_action( 'init', 'locus_addmenus' );
 
function locus_nav() {
    if ( function_exists( 'wp_nav_menu' ) )
        wp_nav_menu( 'container=&container_class=&fallback_cb=locus_nav_fallback' );
    else
        locus_nav_fallback();
}
 
function locus_nav_fallback() {
    wp_page_menu( 'show_home=0&include=999' );
}	

/** Clear */
function clear_shortcode( $atts, $content = null ) {
   return '<div class="clearfix"></div>';
}
add_shortcode('clear', 'clear_shortcode');


/** BR */
function br_shortcode( $atts, $content = null ) {
   return '<br />';
}
add_shortcode('br', 'br_shortcode');

/**
 * Image
 */
function image_shortcode($atts) {
	extract(shortcode_atts(array(		
		"url" => "",
		"img" => "",
		"alt" => "",
		"align" => "",
		"border" => "",
		"width" => "",
		"height" => "",
		"lightbox" => 'false'
	), $atts));
	
	if ( $img == '' )
		return NULL;
	
	if( $lightbox == 'true' )
		$img_rel = 'rel="zoombox"';
		
	if( $url != '' & $width != '' & $height != '') {
		$output  .=  "\n" . '<a href="' . $url . '" ' . $img_rel . '><img src="' . $img . '" class="' . $align . '' . $border . '" width="' . $width . '" height="' . $height . '" alt="' . $alt . '" title="' . $alt . '" ' . $class . '/></a>';
	} elseif( $url != '' )  {
		$output  .=  "\n" . '<a href="' . $url . '" ' . $img_rel . '><img src="' . $img . '" class="' . $align . '' . $border . '" alt="' . $alt . '" title="' . $alt . '" ' . $class . '/></a>';
	} elseif( $width != '' & $height != '' )  {
		$output  .=  "\n" . '<img src="' . $img . '" class="' . $align . '' . $border . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '" title="' . $alt . '" ' . $class . '/>';
	} else {
		$output  .=  "\n" . '<img src="' . $img . '" alt="' . $alt . '" title="' . $alt . '" class="' . $align . '' . $border . '"/>';
	}
	
	return $output;
}
add_shortcode('image', 'image_shortcode');


/**
 * Video
 */
function video_shortcode($atts, $content = null) {	
	return '<div>' . do_shortcode($content) . '</div>';
}
add_shortcode('video', 'video_shortcode');

/**
 * Mini-Services
 */
function mini_services_shortcode($atts, $content = null) {	
	return '<div id="mini-services">' . do_shortcode($content) . '</div>';
}
add_shortcode('mini_services', 'mini_services_shortcode');


/**
 * Dropcap
 */
function dropcap_shortcode($atts, $content = null) {	
	return '<span class="dropcap">' . do_shortcode($content) . '</span>';
}
add_shortcode('dropcap', 'dropcap_shortcode');

/**
 * Dropcap2
 */
function dropcap2_shortcode($atts, $content = null) {	
	return '<span class="dropcap2">' . do_shortcode($content) . '</span>';
}
add_shortcode('dropcap2', 'dropcap2_shortcode');

/**
 * Nivo Slider
 */
function nivo_slider_shortcode( $atts, $content = null ) {
   return '<div id="slider">
      <div id="sliderholder">
      '.remove_wpautop($content).'</div></div>';
}
add_shortcode('nivo_slider', 'nivo_slider_shortcode');


/**
 * Cycle Slider
 */
function cycle_slider_shortcode( $atts, $content = null ) {
   return ' <div id="slider-cycle">
    <div id="sliderholder-cycle">
      '.remove_wpautop($content).'
    </div>
    
    <ul class="slidernav"></ul>
    
    <div class="sliderdir">
        <a href="#"><span class="sliderprev">Prev</span></a> 
        <a href="#"><span class="slidernext">Next</span></a>

        
    </div>
    </div>';
}
add_shortcode('cycle_slider', 'cycle_slider_shortcode');


?>